package cn.edu.scau.cmi.yanweijie.client;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;

import cn.edu.scau.cmi.yanweijie.jdbc.Instructor;
import cn.edu.scau.cmi.yanweijie.jdbc.InstructorMapper;
import cn.edu.scau.cmi.yanweijie.jdbc.Student;
import cn.edu.scau.cmi.yanweijie.jdbc.StudentMapper;
import cn.edu.scau.cmi.yanweijie.jdbc.StudentService;

public class SpringJdbcClient {
	
	public static void main(String[] args) {
		ApplicationContext ac = new ClassPathXmlApplicationContext("resource/spring-config.xml");
		StudentMapper studentMapper = ac.getBean(StudentMapper.class);
		InstructorMapper instructorMapper = ac.getBean(InstructorMapper.class);

		Student student = new Student();
		student = studentMapper.getStudentByName("zhangsan");
		System.out.println("获取学生信息，输出："+student.toString());
		int id= student.getInstructorId();
		System.out.println("获取到该学生的老师的id号 :"+id);
		String instructorNameString = instructorMapper.getInstructor(id).getInstructorName();
		//System.out.println("查询出对应老师的个人信息: "+instructorMapper.getInstructor(id).toString());
		System.out.println("老师的名称为："+instructorMapper.getInstructor(id).getInstructorName());
	}
}
